package com.atguigu.springcloud.payment;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class TestController {

    @Autowired
    private RestTemplate restTemplate;

    @Value("${server.port}")
    private String serverPort;

    @Value("${service-url.nacos-consumer-service}")
    private String consumerServiceURL;

    @GetMapping(value = "/payment_to/{str}")
    public String rest(@PathVariable String str) {
        String url = consumerServiceURL + "/consumer_re/" + str;
        System.out.println("URL:" + url);
        return restTemplate.getForObject(url, String.class);
    }
    @GetMapping(value = "/payment_re/{str}")
    public String feign(@PathVariable String str) {
        return "consumer-->payment  : return payment-server(payment_re) " + str + " Port : " + serverPort ;
    }
}